package com.flex.showdoc4j.filter;

import java.util.LinkedHashSet;
import java.util.Set;

/**
 * 包含需要解析mvc过滤器
 *
 * @author ganlt<br>
 * @since 2019/06/28 17:08 <br>
 */
public class IncludeMvcFilter implements MvcFilter {
    private Set<String> includs = new LinkedHashSet<>();

    public MvcFilter addPatterUrl(String patterUrl) {
        includs.add(removeSlash(patterUrl));
        return this;
    }


    @Override
    public boolean match(String url) {
        if (includs.isEmpty()) {
            return true;
        }
        return includs.contains(removeSlash(url));
    }

    private String removeSlash(String str) {
        return str.replace("/","");
    }
}
